//
//  CouponDetaiController.m
//  FD
//
//  Created by Yasin on 2018/10/15.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
// 纯代码 0.5 小时
//3:30  ==== 4:15

#import "CouponDetaiController.h"

@interface CouponDetaiController ()
/**上面的带边框的背景图片， 应该是一个图片 */
@property (nonatomic, strong)UIImageView *upBgView;
/**1.图标*/
@property (nonatomic, strong)UIImageView *iconIv;
/**2.nameLb 优惠券姓名 */
@property (nonatomic, strong)UILabel *nameLb;
/**3.外送 lb*/
@property (nonatomic, strong)UILabel *waiSongLb;
/**4.有效期 lb*/
@property (nonatomic, strong)UILabel *timeLb;

/**使用说明， 名字就是 使用说明 */
@property (nonatomic, strong) UILabel *shuoMingLb;
/**使用说明， 详情*/
@property (nonatomic, strong) UILabel *shuoMingDetailLb;
/**立即领取*/
@property (nonatomic, strong) UIButton *getNowBtn;
@end

@implementation CouponDetaiController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setupView];
    
    [self setupLayout];
}
- (void)setupView {
    self.navigationItem.title = @"优惠券详情";
    
    [self.view addSubview:self.upBgView];
    [self.upBgView addSubview:self.nameLb];
    [self.upBgView addSubview:self.waiSongLb];
    [self.upBgView addSubview:self.iconIv];
    [self.upBgView addSubview:self.timeLb];


    [self.view addSubview:self.shuoMingLb];
    [self.view addSubview:self.shuoMingDetailLb];
    [self.view addSubview:self.getNowBtn];
}

#pragma mark - 布局
- (void)setupLayout {
    
    //h:120
    [self.upBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).offset(64 + 20);
        make.left.equalTo(self.view.mas_left).offset(10);
        make.right.equalTo(self.view.mas_right).offset(-10);
        make.height.mas_equalTo(120);
    }];
    [self.iconIv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.upBgView.mas_left).offset(5);
        make.size.mas_equalTo(CGSizeMake(80, 80));
        make.centerY.equalTo(self.upBgView.mas_centerY);
    }];
    [self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconIv.mas_right).offset(10);
        make.top.equalTo(self.upBgView.mas_top).offset(10);
        make.height.mas_equalTo(45);
        make.right.mas_equalTo(self.upBgView.mas_right).offset(-10);
    }];
    
    [self.timeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconIv.mas_right).offset(10);
        make.top.equalTo(self.nameLb.mas_bottom).offset(5);
        make.height.mas_equalTo(30);
        make.right.equalTo(self.upBgView.mas_right).offset(10);
    }];
    [self.waiSongLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(100, 30));
        make.top.equalTo(self.upBgView.mas_top);
        make.right.equalTo(self.upBgView.mas_right);
    }];
    
    //-----========
    [self.shuoMingLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(10);
        make.top.equalTo(self.upBgView.mas_bottom).offset(20);
        make.size.mas_equalTo(CGSizeMake(100, 30));
    }];
    
    [self.shuoMingDetailLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.shuoMingLb.mas_bottom).offset(10);
        make.left.equalTo(self.view.mas_left).offset(10);
        make.right.equalTo(self.view.mas_right).offset(-15);
        make.bottom.equalTo(self.getNowBtn.mas_top).offset(-10);
    }];
    
    [self.getNowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(10);
        make.right.equalTo(self.view.mas_right).offset(-10);
        make.bottom.equalTo(self.view.mas_bottom).offset(-40);
        make.height.mas_equalTo(40);
    }];
    
}

#pragma mark - getter
//没有图片先给一个背景颜色
- (UIImageView *)upBgView {
    if (!_upBgView) {
        _upBgView = [[UIImageView alloc] init];
//        _upBgView.backgroundColor = [UIColor lightGrayColor];
    }
    return _upBgView;
}
- (UIImageView *)iconIv {
    if (!_iconIv) {
        _iconIv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"发现cell图标"]];
    }
    return _iconIv;
}
- (UILabel *)nameLb {
    if (!_nameLb) {
        _nameLb = [UILabel new];
        _nameLb.text = @"显卡就分开了的减肥了咖啡福建安东尼空数据";
        _nameLb.numberOfLines = 0;
    }
    return _nameLb;
}
- (UILabel *)timeLb {
    if (!_timeLb) {
        _timeLb = [UILabel new];
        _timeLb.text = [NSString stringWithFormat:@"有效期:2018-10-16至2018-10-20"];
        _timeLb.font = [UIFont systemFontOfSize:12.0];
        _timeLb.textColor = [UIColor lightGrayColor];
    }
    return _timeLb;
}
- (UILabel *)waiSongLb {
    if (!_waiSongLb) {
        _waiSongLb = [UILabel new];
        _waiSongLb.textColor = [UIColor whiteColor];
        _waiSongLb.text = @"外送";
        _waiSongLb.backgroundColor = [UIColor redColor];
    }
    return _waiSongLb;
}
- (UILabel *)shuoMingLb {
    if (!_shuoMingLb) {
        _shuoMingLb = [UILabel new];
        _shuoMingLb.text = @"使用说明";
        _shuoMingLb.backgroundColor = [UIColor redColor];
    }
    return _shuoMingLb;
}
- (UILabel *)shuoMingDetailLb {
    if (!_shuoMingDetailLb) {
        _shuoMingDetailLb = [UILabel new];
        _shuoMingDetailLb.text = @"jkaljfla解放路的撒酒疯俩精神分裂按揭贷款房间爱你放假ADSL房价阿里机房那就是地方了看见爱的是考虑到附近按钮看地方了卡设计费那设计费急啊疯狂夺金福利卡还浪费金卡戴珊金风科技回复接口大师傅驾考就放开那是荆防颗粒阿斯利康放大镜阿里机房蒂娜积分拿的教科书法拉盛复健科辣椒粉那时间段覅发梳考虑到附近ad时空裂缝敬爱的可能是房价爱的是考虑到发生的龙卷风l";
        _shuoMingDetailLb.numberOfLines = 0;
        _shuoMingDetailLb.backgroundColor = [UIColor brownColor];
        _shuoMingDetailLb.textColor = [UIColor lightGrayColor];
    }
    return _shuoMingDetailLb;
}

- (UIButton *)getNowBtn {
    if (!_getNowBtn) {
        _getNowBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_getNowBtn setTitle:@"立即获取" forState:(UIControlStateNormal)];
        [_getNowBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
        _getNowBtn.backgroundColor = [UIColor redColor];
        _getNowBtn.layer.masksToBounds = YES;
        _getNowBtn.layer.cornerRadius = 5;
        [_getNowBtn addTarget:self action:@selector(getNowBtnAction:) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _getNowBtn;
}



#pragma mark - 点击事件

#pragma mark - 点击事件
- (void)getNowBtnAction:(UIButton *)btn {
    
    [JRToast showWithText:NSLocalizedString(ToastReceived, @"已经领取")];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
